﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package reprise.controls.html {
    import flash.events.*;
    import reprise.external.*;
    import reprise.css.*;
    import reprise.events.*;
    import flash.display.*;
    import reprise.controls.*;

    public class Image extends BitmapElement {

        protected var m_priority:int;// = 0
        protected var m_loaded:Boolean;
        protected var m_imageLoader:BitmapResource;
        private var m_cacheBitmap:Boolean = true

        public static const className:String = "img";

        protected function imageLoaded(_arg1:ResourceEvent):void{
            if (!_arg1.success){
                dispatchEvent(new DisplayEvent(DisplayEvent.LOAD_FAIL));
                return;
            };
            m_loaded = true;
            setBitmapData(BitmapData(m_imageLoader.content()));
            m_imageLoader.removeEventListener(Event.COMPLETE, imageLoaded);
            m_imageLoader = null;
            dispatchEvent(new DisplayEvent(DisplayEvent.LOAD_COMPLETE));
        }
        public function setSrc(_arg1:String):void{
            if (!_arg1){
                return;
            };
            _arg1 = CSSParsingHelper.resolvePathAgainstPath(_arg1, m_xmlURL);
            m_loaded = false;
            if (m_imageLoader){
                m_imageLoader.cancel();
            };
            m_imageLoader = new BitmapResource();
            m_imageLoader.priority = m_priority;
            m_imageLoader.setCacheBitmap(m_cacheBitmap);
            m_imageLoader.setURL(_arg1);
            m_imageLoader.addEventListener(Event.COMPLETE, imageLoaded);
            m_imageLoader.execute();
        }
        override public function remove(... _args):void{
            if (m_imageLoader){
                m_imageLoader.cancel();
                m_imageLoader.removeEventListener(Event.COMPLETE, imageLoaded);
                m_imageLoader = null;
            };
            super.remove(_args);
        }
        public function setPriority(_arg1:int):void{
            m_priority = _arg1;
            if (m_imageLoader){
                m_imageLoader.priority = _arg1;
            };
        }
        override protected function applyInFlowChildPositions():void{
            if (m_loaded){
                super.applyInFlowChildPositions();
            };
        }
        public function setCacheBitmap(_arg1:Boolean):void{
            m_cacheBitmap = _arg1;
        }
        public function cacheBitmap():Boolean{
            return (m_cacheBitmap);
        }
        public function setCheckPolicyFile(_arg1:Boolean):void{
        }
        public function loader():IResource{
            return (m_imageLoader);
        }
        public function checkPolicyFile():Boolean{
            return (true);
        }

    }
}//package reprise.controls.html 
